{include file="public/toper"/}
<style>
    .layui-unselect{width: 190px;}
</style>
<div class="x-body">
    <form class="layui-form" id="admin">
        <input type="hidden" name="materiel_id" value="{$list['materiel_id']}">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>物料编码
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$list['code']}" name="code" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>10个字符以内
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>物料名称
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$list['name']}" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>10个字符以内
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>选择上级</label>
            <div class="layui-input-block">
                <select name="parent_id" lay-verify="">
                    <option value="0">顶级</option>
                    {volist name="pare" id="vo"}
                    <option value="{$vo.materiel_id}"
                            {if condition="$list['name']"}
                            {if condition="$vo['materiel_id'] eq $list['parent_id']"} selected="selected"{/if}{/if}>{$vo['name']}
                    </option>
                    {/volist}
                </select>
            </div>
        </div>
        <span class="x-red">*根据结算规则（销售价 * X% +　成本价 * Y　＋　调剂值 Z，缺省值优先从二级物料类优先获取，若没有特殊设置，则从一级物料设置中取，若都没有，就从全系统选择</span>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>缺省值z
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$list['value_z']}" name="value_z" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>缺省值x
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$list['value_x']}" name="value_x" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>缺省值y
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$list['value_y']}" name="value_y" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>押金
            </label>
            <div class="layui-input-inline">
                <input type="number" value="{$list['deposit']}" name="deposit" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>租金
            </label>
            <div class="layui-input-inline">
                <input type="number" value="{$list['rent']}" name="rent" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>商家结算
            </label>
            <div class="layui-input-inline">
                <input type="number" value="{$list['settlement']}" name="settlement" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>一级佣金
            </label>
            <div class="layui-input-inline">
                <input type="number" value="{$list['one_proportion']}" name="one_proportion" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>百分比
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>二级佣金
            </label>
            <div class="layui-input-inline">
                <input type="number" value="{$list['two_proportion']}" name="two_proportion" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>百分比
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="admin" lay-submit>提交</button>
        </div>
    </form>
</div>

<script>
    layui.use(['form'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;


        //监听提交
            form.on('submit(admin)', function(data) {
                $.ajax({
                    url:"{:url('Materiel/add')}",
                    data:$('#admin').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        if(res.code == 200) {
                            layer.alert(res.msg, {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                parent.location.reload();
                            })
                        } else {
                            layer.msg(res.msg,{icon: 2});
                        }
                    }
                });
                return false;
            });


    });
</script>
{include file="public/footer"/}